<?php
/*
Plugin Name: odCatalogWpPlugin
Plugin URI: http://www.ondrejd.info/projects/wordpress-plugins/od-catalog-plugin/
Description: Plugin for creating catalog sites with your WordPress
Version: 0.1
Author: Ondrej Donek
Author URI: http://www.ondrejd.info/
*/

/*  ***** BEGIN LICENSE BLOCK *****
    Version: MPL 1.1
    
    The contents of this file are subject to the Mozilla Public License Version 
    1.1 (the "License"); you may not use this file except in compliance with 
    the License. You may obtain a copy of the License at 
    http://www.mozilla.org/MPL/
    
    Software distributed under the License is distributed on an "AS IS" basis,
    WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
    for the specific language governing rights and limitations under the
    License.
    
    The Original Code is odCatalogWpPlugin.
    
    The Initial Developer of the Original Code is
    Ondrej Donek.
    Portions created by the Initial Developer are Copyright (C) 2010
    the Initial Developer. All Rights Reserved.
    
    Contributor(s):
    
    ***** END LICENSE BLOCK ***** */

// Include odWpPlugin
require_once realpath(dirname(__FILE__) . '/odWpPlugin.php');


#{{{ odCatalogWpPlugin_Models_Address ---
if(!class_exists('odCatalogWpPlugin_Models_Address')):
#!src_models_Address##
endif;
#}}} --- odCatalogWpPlugin_Models_Address


#{{{ odCatalogWpPlugin_Models_Category ---
if(!class_exists('odCatalogWpPlugin_Models_Category')):
#!src_models_Category##
endif;
#}}} --- odCatalogWpPlugin_Models_Category


#{{{ odCatalogWpPlugin_Models_Item ---
if(!class_exists('odCatalogWpPlugin_Models_Item')):
#!src_models_Item##
endif;
#}}} --- odCatalogWpPlugin_Models_Item


#{{{ odCatalogWpPlugin_Models_User ---
if(!class_exists('odCatalogWpPlugin_Models_User')):
#!src_models_User##
endif;
#}}} --- odCatalogWpPlugin_Models_User


#{{{ odCatalogWpPlugin_Forms_Category ---
if(!class_exists('odCatalogWpPlugin_Forms_Category')):
#!src_forms_Category##
endif;
#}}} --- odCatalogWpPlugin_Forms_Category


#{{{ odCatalogWpPlugin_Forms_Item ---
if(!class_exists('odCatalogWpPlugin_Forms_Item')):
#!src_forms_Item##
endif;
#}}} --- odCatalogWpPlugin_Forms_Item


#{{{ odCatalogWpPlugin_Tables_Category ---
if(!class_exists('odCatalogWpPlugin_Tables_Category')):
#!src_tables_Category##
endif;
#}}} --- odCatalogWpPlugin_Tables_Category


#{{{ odCatalogWpPlugin_Tables_User ---
if(!class_exists('odCatalogWpPlugin_Tables_User')):
#!src_tables_User##
endif;
#}}} --- odCatalogWpPlugin_Tables_User

#{{{ odCatalogWpPlugin ---
if(!class_exists('odCatalogWpPlugin')):

/**
 * Main catalog object
 * 
 * @author Ondrej Donek, <ondrejd@gmail.com>
 * @category odCatalogWpPlugin
 * @version 0.1
 */
class odCatalogWpPlugin extends odWpPlugin
{
	/**
	 * Constructor.
	 *
	 * @return void
	 */
	public function __construct()
	{
		parent::__construct(
			'od-catalog-wpplugin',
			'odCatalogWpPlugin',
			'##VERSION##', 
			array(
				'hasAdmin' => true,
				'adminConfig' => array(
					'stylesheet' => true
				),
				'hasLocales' => true,
				'hasOptions' => true, 
				'defaultOptions' => array(
          'catalog_page_id' => 9,
          'registration_form_page_id' => 4,
          'createaccount_form_page_id' => 6
				)
			)
		);
    
		// Activation/deactivation
		register_activation_hook(__FILE__, array(&$this, 'activate'));
		register_deactivation_hook(__FILE__, array(&$this, 'deactivate'));
		
		// Ensure that plugin's options are initialized
		$options = $this->initOptions();
		
		if(is_admin()) {
			// TODO Add AJAX check for new galleries directories
			//add_action('admin_print_scripts', array(&$this, 'js_admin_header'));
			//add_action('wp_ajax_catalog_check_dir', array(&$this, 'ajax_check_if_dir_exist'));
			
			// Register admin menu
			add_action('admin_menu', array(&$this, 'adminMenu'));
			
			// TODO Register top quick admin menus
			
			// TODO Register TinyMCE buttons
			// add_action('init', array(&$this, 'register_tinymce_buttons'));
			
			// TODO Register our dashboard widget
		}
		else {
      // Register content filter
      add_filter('the_content', array(&$this, 'contentFilter'));
      
      // Initialize plugin's widgets
      //register_widget('odWpCatalogpanelWidget');
      //register_widget('odWpCataloglist1Widget');
		}
  }, // end __construct()
	
	/**
	 * Activates the plugin
	 * 
	 * @returns void
	 */
	public function activate()
	{
		// Ensure that database tables are created
		$categoryModel = new odCatalogWpPlugin_Models_Category();
		$itemModel = new odCatalogWpPlugin_Models_Item();
		$userModel = new odCatalogWpPlugin_Models_User();
		
		$categoryModel->createTable();
		$itemModel->createTable();
		$userModel->createTable();
		//exit();
	} // end activate()

	/**
	 * Deactivates the plugin
	 * 
	 * @returns void
	 */
	public function deactivate()
	{ 
		// TODO Destroy database if user want it! 
	} // end deactivate()
	
	/**
	 * Registers administration menu for the plugin
	 * 
	 * @returns void
	 */
	public function adminMenu() 
	{
		add_menu_page(
				__('Katalog', self::TEXTDOMAIN),
				__('Katalog', self::TEXTDOMAIN),
				0,
				self::ID,
				array(&$this, 'adminCatalogItems'),
				WP_PLUGIN_URL . '/' . self::ID . '/icon16.png'
		);
		add_submenu_page(
				self::ID,
				__('Katalog - Přidej položku', self::TEXTDOMAIN),
				__('Nová položka', self::TEXTDOMAIN),
				0,
				self::ID . '-add_item',
				array(&$this, 'adminAddCatalogItem')
		);
		add_submenu_page(
				self::ID,
				__('Katalog - Kategorie', self::TEXTDOMAIN),
				__('Kategorie', self::TEXTDOMAIN),
				0,
				self::ID . '-categories',
				array(&$this, 'adminCatalogCategories')
		);
		add_submenu_page(
				self::ID,
				__('Katalog - Přidej kategorii', self::TEXTDOMAIN),
				__('Nová kategorie', self::TEXTDOMAIN),
				0,
				self::ID . '-add_category',
				array(&$this, 'adminAddCatalogCategory')
		);
		add_submenu_page(
				self::ID,
				__('Katalog - Registrovaní uživatelé', self::TEXTDOMAIN),
				__('Uživatelé', self::TEXTDOMAIN),
				0,
				self::ID . '-registered_users',
				array(&$this, 'adminRegisteredUsers')
		);
		add_submenu_page(
				self::ID,
				__('Katalog - Nastavení', self::TEXTDOMAIN),
				__('Nastavení', self::TEXTDOMAIN),
				0,
				self::ID . '-settings',
				array(&$this, 'adminSettingsPage')
		);
	}
	
	/**
	 * Renders admin page with catalog items.
	 * 
	 * @returns void
	 */
	public function adminCatalogItems()
	{
		throw new Exception('Not implemented yet!');
	} // end adminCatalogItems()
	
	/**
	 * Renders add admin page for plugin FOTOGALERIE.
	 * 
	 * @return void
	 */
	public function adminAddCatalogItem()
	{
		$title = __('Katalog - Přidej položku katalogu', self::TEXTDOMAIN);
		$icon  = WP_PLUGIN_URL . '/' . self::ID . '/icon32.png';
		$form = new odCatalogWpPlugin_Forms_Item();
		
		// ...
		
		$content = $form->render();
		
		$this->mRenderer->adminPage($title, $content, $icon);
	} // end adminAddCatalogItem()
	
	/**
	 * Render admin page for catalog categories.
	 *
	 * @return void
	 */
	public function adminCatalogCategories() 
	{
		$title = __('Katalog - Kategorie', self::TEXTDOMAIN);
		$icon  = WP_PLUGIN_URL . '/' . self::ID . '/icon32.png';
		$table = new odCatalogWpPlugin_Tables_Category();
		$content = $table->render();
		
		$this->mRenderer->adminPage($title, $content, $icon);
	} // end adminCategories()
	
	/**
	 * Renders add catalog category page.
	 *
	 * @return void
	 */
	public function adminAddCatalogCategory()
	{
		$title = __('Katalog - Přidej kategorii', self::TEXTDOMAIN);
		$icon  = WP_PLUGIN_URL . '/' . self::ID . '/icon32.png';
		$form = new odCatalogWpPlugin_Forms_Category();
		
		if(isset($_GET['item_ID'])) {
			$item_id = (int) $_GET['item_ID'];
			$title = __('Katalog - Edituj kategorii #', self::TEXTDOMAIN) . $item_id;
			$model = new odCatalogWpPlugin_Models_Category();
			$item = $model->get('`t1`.ID = ' . $item_id);
			$form->setValues($item[0]);
		}
		
		$this->mRenderer->adminPage($title, $form->render(), $icon);
	}
	
	/**
	 * Renders table with registered users.
	 *
	 * @return void
	 */
	public function adminRegisteredUsers()
	{
		$title = '';
		$icon  = WP_PLUGIN_URL . '/' . self::ID . '/icon32.png';
		$content = '';
		
		if(array_key_exists('item_ID', $_GET)) {
			$model = new odCatalogWpPlugin_Models_User();
			$user = $model->get('`t1`.`ID` = ' . (int) $_GET['item_ID']);
			
			if(count($user) != 1) {
				$content = '<p style="font-weight:bold; color:#f30;">Vybraný ' .
						'uživatel (ID <code>' . (int) $_GET['item_ID'] . '</code>) ' .
						'nebyl v databázi nalezen!</p>' . PHP_EOL;
			} else {
				$user = $user[0];
				$title = __('Katalog - Uživatel #', self::TEXTDOMAIN) . (int) $_GET['item_ID'];
				$tableUrl = get_bloginfo('home') .'/wp-admin/admin.php?page=od-catalog-registered_users';
				
				$content .= '<table cellspacing="0" cellpadding="0" style="width:70%;">' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Titul:<th><td>' . $user['titul'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Příjmení:<th><td>' . $user['prijmeni'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Jméno:<th><td>' . $user['jmeno'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Národnost:<th><td>' . $user['narodnost'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Jazyk:<th><td>' . $user['jazyk'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Bydliště:<th><td>' . $user['bydliste'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Ulice:<th><td>' . $user['ulice'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Město:<th><td>' . $user['mesto'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">PSČ:<th><td>' . $user['psc'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">E-mail:<th><td>' . $user['email'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Mobilní telefon:<th><td>' . $user['mobil'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Další telefon:<th><td>' . $user['telefon'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Datum narození:<th><td>' . $user['narozeni'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Pohlaví:<th><td>' . $user['pohlavi'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Děti:<th><td>' . (((int)$user['deti']==0)?'ne':'ano') . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Zájmy:<th><td>' . $user['zajmy'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Souhlas:<th><td>' . (((int)$user['souhlas']==0)?'ne':'ano') . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Karta:<th><td>' . $user['karta'] . '</td></tr>' . PHP_EOL;
				$content .= '<tr><th style="text-align:left;">Odkud zná <em>LoyaltyPlanet Card</em>:<th><td>' . $user['odkud'] . '</td></tr>' . PHP_EOL;
				$content .= '</table>' . PHP_EOL;
				$content .= '<p><a href="' . $tableUrl . '">' . __('Zpět na přehled uživatelů', self::TEXTDOMAIN) . '</a></p>' . PHP_EOL;
			}
		} else {
			$title = __('Katalog - Registrovaní uživatelé', self::TEXTDOMAIN);
			$table = new odCatalogWpPlugin_Tables_User();
			$content .= $table->render();
		}
		
		$this->mRenderer->adminPage($title, $content, $icon);
	}
	
	/** 
	 * Renders settings page for the plugin
	 * 
	 * @return void
	 */
	public function adminSettingsPage()
	{
		$title = __('Katalog - Nastavení', self::TEXTDOMAIN);
		$icon  = WP_PLUGIN_URL . '/' . self::ID . '/icon32.png';
		$formUrl = get_bloginfo('home') .'/wp-admin/admin.php?page=od-catalog-settings';
		$options = $this->getOptions();
		
		if(isset($_POST['settings_save'])){
			$options['catalog_page_id'] = (int) $_POST['option-catalog_page_id']; 
			$options['registration_form_page_id'] = (int) $_POST['option-registration_form_page_id']; 
			$options['createaccount_form_page_id'] = (int) $_POST['option-createaccount_form_page_id']; 
			update_option(self::ID . '-options', $options);
			
			$this->mRenderer->adminMsg(__('Nastavení pluginu bylo aktualizováno.', self::TEXTDOMAIN));
		}
		
		$content  = '<form action="' . $formUrl . '" method="post" enctype="multipart/form-data">' . PHP_EOL;
		$content .= '	<div>' . PHP_EOL;
		$content .= '		<table class="widefat post fixed" cellpadding="1" cellspacing="1" style="100%;">' . PHP_EOL;
		$content .= '			<tr>' . PHP_EOL;
		$content .= '				<th scope="row"><label for="option-catalog_page_id">' . __('ID stránky s katalogem:', odCatalogWpPlugin::TEXTDOMAIN) . '</label></th>' . PHP_EOL;
		$content .= '				<td><input type="text" name="option-catalog_page_id" value="' . $options['catalog_page_id'] . '" style="min-width: 300px;"/></td>' . PHP_EOL;
		$content .= '			</tr>' . PHP_EOL;
		$content .= '			<tr>' . PHP_EOL;
		$content .= '				<th scope="row"><label for="option-registration_form_page_id">' . __('ID stránky s registračním formulářem:', odCatalogWpPlugin::TEXTDOMAIN) . '</label></th>' . PHP_EOL;
		$content .= '				<td><input type="text" name="option-registration_form_page_id" value="' . $options['registration_form_page_id'] . '" style="min-width: 300px;"/></td>' . PHP_EOL;
		$content .= '			</tr>' . PHP_EOL;
		$content .= '			<tr>' . PHP_EOL;
		$content .= '				<th scope="row"><label for="option-createaccount_form_page_id">' . __('ID stránky s formulářem pro vytvoření firemních účtů:', odCatalogWpPlugin::TEXTDOMAIN) . '</label></th>' . PHP_EOL;
		$content .= '				<td><input type="text" name="option-createaccount_form_page_id" value="' . $options['createaccount_form_page_id'] . '" style="min-width: 300px;"/></td>' . PHP_EOL;
		$content .= '			</tr>' . PHP_EOL;
		$content .= '		</table>' . PHP_EOL;
		$content .= '		<input type="submit" value=" ' . __('Save', odCatalogWpPlugin::TEXTDOMAIN) . ' " name="settings_save" class="button-primary action" />' . PHP_EOL;
		$content .= '	</div>' . PHP_EOL;
		$content .= '</form>' . PHP_EOL;
		
		$this->mRenderer->adminPage($title, $content, $icon);
	}
	
	/**
	 * Content filter.
	 *
	 * @param string $aContent
	 * @return void
	 */
	public function contentFilter($aContent)
	{
		// Catalog page
		if(strpos($aContent, '[catalog_page]') !== false) {
			$main_page = $this->renderCatalogPage();
			return str_replace('<p>[catalog_page]</p>', $main_page, $aContent);
		}
		
		// Members registration form
		if(strpos($aContent, '[registration_form]') !== false) {
			$main_page = $this->renderRegistrationForm();
			return str_replace('<p>[registration_form]</p>', $main_page, $aContent);
		}
		
		// Firms registration form
		if(strpos($aContent, '[createaccount_form]') !== false) {
			$main_page = $this->renderCreateAccountForm();
			return str_replace('<p>[createaccount_form]</p>', $main_page, $aContent);
		}
	}
	
	/**
	 * Returns correct URL for the catalog page.
	 *
	 * @return string
	 */
	public function getCatalogPageUrl()
	{
		//$options = $this->getDefaultOptions();
		//$catalogPageId = $options['catalog_page_id'];
		//$catalogPageLink = get_permalink($catalogPageId);
		
		// TODO !!!!!!!!!!!!!!!!!
		$catalogPageLink = get_bloginfo('home') . '/catalog/';
		
		
		return $catalogPageLink;
	}
	
	/**
	 * Renders catalog page.
	 *
	 * @return string
	 */
	public function renderCatalogPage()
	{
		$categoryModel = new odCatalogWpPlugin_Models_Category();
		$parent_category = (array_key_exists('category_ID', $_GET))
				? (int) $_GET['category_ID']
				: 0;
		$categories = $categoryModel->get('`t1`.`parent_ID` = ' . $parent_category . ' ' .
										  'AND `t1`.`deleted` = 0 ' .
										  'AND `t1`.`locale` = \'en\'');
		
		$output = '';
		$output .= '<table class="datatable" width="100%" border="0" cellspacing="0" cellpadding="0">' . PHP_EOL;
		$output .= $this->_renderCategoriesTree($categories, 'TABLE', false);
		$output .= '</table>';
		
		return $output;
	}
	
	/**
	 * Renders categories tree. Array should be in form such this:
	 * <pre>
	 * array(
	 *   0 => array('ID' => 1, 'title' => 'Some title'),
	 *   1 => array('ID' => 2, 'title' => 'Some title', 'children' => array(
	 *     0 => array('ID' => 4, 'title' => 'Some title', 'children' => array(
	 *       0 => array('ID' => 7, 'title' => 'Some title', 'children' => array(
	 *         ...
	 *       ))
	 *     )),
	 *     1 => array('ID' => 5, 'title' => 'Some title'),
	 *     2 => array('ID' => 6, 'title' => 'Some title'),
	 *     ...
	 *   )),
	 *   2 => array('ID' => 3, 'title' => 'Some title'),
	 *   ...
	 * )
	 * </pre>
	 *
	 * @param array $aCategories
	 * @param string $aType Optional (defaultly 'LIST'). Type of the used renderer.
	 *                      Available types of renderers: 'LIST', 'TABLE'.
	 * @param boolean $aRenderChildren Optional (defaultly TRUE).
	 * @return string
	 */
	public static function _renderCategoriesTree($aCategories = null, $aType = 'LIST', $aRenderChildren = true)
	{
		if(!is_array($aCategories)) {
			return '';
		}
		
		global $od_wp_catalog_plugin;
		$catalogUrl = $od_wp_catalog_plugin->getCatalogPageUrl();
		$output = '';
		$ii = 0;
		
		for($i = 0; $i<count($aCategories); $i++) {
			$cat = $aCategories[$i];
			
			if(is_array($cat)) {
				$url = $catalogUrl . '?category_ID=' . $cat['ID'];
				$hasChildren = false;
				
				if($aRenderChildren === true)
					if(array_key_exists('children', $cat)) 
						if(is_array($cat['children']) && count($cat['children']) > 0) 
							$hasChildren = true;
				
				if($hasChildren === true) {
					$children = self::_renderCategoriesTree($cat['children'], $aType);
					
					if($aType == 'LIST') {
						$output .= '<li><a href="' . $url . '">' . $cat['title'] . '</a>' . PHP_EOL;
						$output .= '<ul>' . $children . '</ul>';
						$output .= '</li>';
					}
					else {
						throw new Exception('Cann\'t render children when using `TABLE` renderer!');
					}
				} else {
					if($aType == 'LIST') {
						$output .= '<li><a href="' . $url . '">' . $cat['title'] . '</a></li>';
					}
					else {
						if($ii == 0) {
							$output .= '<tr class="' . ((($i%2) == 0) ? 'suda' : 'licha') . '">' . PHP_EOL;
						}
						
						$output .= '<td style="width: 25%;"><a href="' . $url . '">' . $cat['title'] . '</a></td>' . PHP_EOL;
						
						if($ii == 3) {
							$output .= '</tr>' . PHP_EOL;
							$ii = 0;
						} else {
							$ii++;
						}
					}
				}
			}
		}
		
		if($ii < 3) {
			for($o = $ii; $o < 3; $o++) {
				$output .= '<td style="width: 25%;">&nbsp;</td>' . PHP_EOL;
			}
			$output .= '</tr>' . PHP_EOL;
		}
		else if($ii == 3) {
			$output .= '</tr>' . PHP_EOL;
		}
		
		return $output;
	}
	
	/**
	 * Renders registration form and returns it.
	 *
	 * @return string
	 */
	public function renderRegistrationForm()
	{
		// TODO Correct form URL!!!
		$options = $this->getOptions();
		$formUrl = get_option('home') . '/?page_id=' . $options['registration_form_page_id'];
		$output = '';
		
		$res = $this->_processRegistrationForm();
		if($res === true) {
			$output = '<p>' . __('Vaše registrace byla úspěšná. Nyní se můžete přihlásit.', self::TEXTDOMAIN) . '</p>' . PHP_EOL;
			return $output;
		} else if(is_array($res)) {
			foreach($res as $msg) {
				$output .= '<p style="colof:#f30; font-weight: bold;">' . $msg . '</p>';
			}
		}
		
		$output .= '<form action="' . $formUrl . '" method="post">' . PHP_EOL;
		//$output .= '	<div class="clanky">' . PHP_EOL;
		$output .= '		<div class="radek">' . PHP_EOL;
		$output .= '			<span class="formular">' . PHP_EOL;
		$output .= '				<label for="jazyk">' . __('Výběr jazyka:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<select name="jazyk" id="jazyk">' . PHP_EOL;
		$output .= '					<option value="cz">' . __('Česky', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '					<option value="sk">' . __('Slovensky', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '					<option value="en">' . __('English', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '					<option value="ru">' . __('Russian', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '				</select>' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '			<span class="formular">' . PHP_EOL;
		$output .= '				<label for="narodnost">' . __('Národnost:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<select name="narodnost" id="narodnost">' . PHP_EOL;
		$output .= '					<option value="cz">' . __('Česká', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '					<option value="sk">' . __('Slovenská', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '					<option value="en">' . __('English', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '					<option value="ru">' . __('Russian', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '				</select>' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '			<span class="formular">' . PHP_EOL;
		$output .= '				<label for="bydliste">' . __('Trvalé bydliště:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<select name="bydliste" id="bydliste">' . PHP_EOL;
		$output .= '					<option value="cz">' . __('Česká republika', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '					<option value="sk">' . __('Slovensko', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '					<option value="en">' . __('Velká Británie', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '					<option value="ru">' . __('Rusko', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '				</select>' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '		</div>' . PHP_EOL;
		$output .= '		<div class="radek">' . PHP_EOL;
		$output .= '			<span class="formular">' . PHP_EOL;
		$output .= '				<label for="titul">' . __('Titul:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<input type="text" name="titul" id="titul" value="" />' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '			<span class="formular">' . PHP_EOL;
		$output .= '				<label for="jmeno">' . __('Jméno:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<input type="text" name="jmeno" id="jmeno" value="" />' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '			<span class="formular">' . PHP_EOL;
		$output .= '				<label for="prijmeni">' . __('Příjmení:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<input type="text" name="prijmeni" id="prijmeni" value="" />' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '		</div>' . PHP_EOL;
		$output .= '		<div class="radek">' . PHP_EOL;
		$output .= '			<span class="formular">' . PHP_EOL;
		$output .= '				<label for="ulice">' . __('Ulice:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<input type="text" name="ulice" id="ulice" value="" />' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '			<span class="formular">' . PHP_EOL;
		$output .= '				<label for="mesto">' . __('Město:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<input type="text" name="mesto" id="mesto" value="" />' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '			<span class="formular">' . PHP_EOL;
		$output .= '				<label for="psc">' . __('PSČ:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<input type="text" name="psc" id="psc" value="" />' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '		</div>' . PHP_EOL;
		$output .= '		<div class="radek">' . PHP_EOL;
		$output .= '			<span class="formular">' . PHP_EOL;
		$output .= '				<label for="email">' . __('Email:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<input type="text" name="email" id="email" value="" />' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '			<span class="formular">' . PHP_EOL;
		$output .= '				<label for="mobil">' . __('Mobilní telefon:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<input type="text" name="mobil" id="mobil" value="" />' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '			<span class="formular">' . PHP_EOL;
		$output .= '				<label for="telefon">' . __('Jiný telefon:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<input type="text" name="telefon" id="telefon" value="" />' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '		</div>' . PHP_EOL;
		$output .= '		<div class="radek">' . PHP_EOL;
		$output .= '			<span class="formular">' . PHP_EOL;
		$output .= '				<label for="narozeni">' . __('Datum narození:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<input type="text" name="narozeni" id="narozeni" value="" />' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '			<span class="formular">' . PHP_EOL;
		$output .= '				<label for="pohlavi">' . __('Pohlaví:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<select name="pohlavi" id="pohlavi">' . PHP_EOL;
		$output .= '					<option value="muz">' . __('Muž', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '					<option value="zena">' . __('Žena', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '				</select>' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '			<span class="formular">' . PHP_EOL;
		$output .= '				<label for="deti">' . __('Děti:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<select name="deti" id="deti">' . PHP_EOL;
		$output .= '					<option value="ano">' . __('Ano', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '					<option value="ne">' . __('Ne', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '				</select>' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '		</div>' . PHP_EOL;
		$output .= '		<div class="radek">' . PHP_EOL;
		$output .= '			<span class="formular siroky">' . PHP_EOL;
		$output .= '				<label for="zajmy">' . __('Zájmy:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<input type="checkbox" name="zajmy[]" id="zajmy" value="1" class="check" /> <b>Gurmánské jídlo</b>' . PHP_EOL;
		$output .= '				<input type="checkbox" name="zajmy[]" value="2" class="check" /> <b>Golf</b>' . PHP_EOL;
		$output .= '				<input type="checkbox" name="zajmy[]" value="3" class="check" /> <b>Móda</b>' . PHP_EOL;
		$output .= '				<input type="checkbox" name="zajmy[]" value="4" class="check" /> <b>Hotel</b>' . PHP_EOL;
		$output .= '				<input type="checkbox" name="zajmy[]" value="5" class="check" /> <b>Vaření</b>' . PHP_EOL;
		$output .= '				<input type="checkbox" name="zajmy[]" value="6" class="check" /> <b>Nákupy</b>' . PHP_EOL;
		$output .= '				<br />' . PHP_EOL;
		$output .= '				<label></label>' . PHP_EOL;
		$output .= '				<input type="checkbox" name="zajmy[]" value="7" class="check" /> <b>Sport</b>' . PHP_EOL;
		$output .= '				<input type="checkbox" name="zajmy[]" value="8" class="check" /> <b>Auto</b>' . PHP_EOL;
		$output .= '				<input type="checkbox" name="zajmy[]" value="9" class="check" /> <b>Kluby</b>' . PHP_EOL;
		$output .= '				<input type="checkbox" name="zajmy[]" value="10" class="check" /> <b>Zdraví a krása </b>' . PHP_EOL;
		$output .= '				<input type="checkbox" name="zajmy[]" value="11" class="check" /> <b>Kultura</b>' . PHP_EOL;
		$output .= '				<input type="checkbox" name="zajmy[]" value="12" class="check" /> <b>Cestování</b>' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '		</div>' . PHP_EOL;
		$output .= '		<p class="datum">&nbsp;</p>' . PHP_EOL;
		$output .= '		<p class="oddeleni"></p>' . PHP_EOL;
		$output .= '		<p class="datum">' . __('Vyplněním svých osobních údajů na tomto formuláři dáváte svůj souhlas se zařazením těchto dat do databáze společnosti COSMOPOLITES, s.r.o., v souladu se zákonem č. 101/2000 Sb., o ochraně osobních údajů, za účelem čerpání výhod vyplývajících z Vašeho členství v LOYALTY PLANET programu. COSMOPOLITES, s.r.o. prohlašuje, že Vaše osobní údaje jsou považovány za přísně důvěrné a budou použity pouze pro informační účely po dobu trvání LOYALTY PLANET programu. Tyto údaje nebudou převedeny na třetí osoby.  Taky souhlasíte, v souladu se Zákonem č. 480/2004 Sb., se zasíláním informací o novinkách a akcích programu elektronickou poštou.', self::TEXTDOMAIN) . '</p>' . PHP_EOL;
		$output .= '		<div class="radek">' . PHP_EOL;
		$output .= '			<span class="formular siroky">' . PHP_EOL;
		$output .= '				<label for="souhlas">' . __('Souhlasíte:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<input type="radio" name="souhlas" id="souhlas" value="ano" class="radio" /> <b>' . __('Ano', self::TEXTDOMAIN) . '</b>' . PHP_EOL;
		$output .= '				<input type="radio" name="souhlas" value="ne" class="radio" /> <b>' . __('Ne', self::TEXTDOMAIN) . '</b>' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '		</div>' . PHP_EOL;
		$output .= '		<p class="datum">&nbsp;</p>' . PHP_EOL;
		$output .= '		<p class="oddeleni"></p>' . PHP_EOL;
		$output .= '		<div class="radek">' . PHP_EOL;
		$output .= '			<span class="formular siroky">' . PHP_EOL;
		$output .= '				<label for="karta">' . __('Vyberte kartu:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<input type="radio" name="karta" id="karta" value="classic" class="radio" /> <i><img src="' . get_bloginfo('stylesheet_directory') . '/img/karta_classic.gif" alt="" /></i> <b>Classic card</b>' . PHP_EOL;
		$output .= '				<input type="radio" name="karta" value="gold" class="radio" /> <i><img src="' . get_bloginfo('stylesheet_directory') . '/img/karta_zlata.gif" alt="" /></i> <b>Gold card</b>' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '		</div>' . PHP_EOL;
		$output .= '		<div class="radek">' . PHP_EOL;
		$output .= '			<span class="formular siroky">' . PHP_EOL;
		$output .= '				<label for="odkud" class="siroky">' . __('Odkud znáte Loyalty Planet card?', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '				<input type="text" name="odkud" id="odkud" value="" class="siroky" />' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '		</div>' . PHP_EOL;
		$output .= '		<p class="datum">&nbsp;</p>' . PHP_EOL;
		$output .= '		<p class="oddeleni"></p>' . PHP_EOL;
		$output .= '		<div class="radek">' . PHP_EOL;
		$output .= '			<span class="formular siroky">' . PHP_EOL;
		$output .= '				<input type="submit" name="registerSubmit" value="' . __('Odeslat', self::TEXTDOMAIN) . '" class="odeslat" />' . PHP_EOL;
		$output .= '			</span>' . PHP_EOL;
		$output .= '		</div>' . PHP_EOL;
		//$output .= '	</div>' . PHP_EOL;
		$output .= '</form>' . PHP_EOL;
		
		return $output;
	}
	
	/**
	 * Process registration form. Returns TRUE if form was correctly submitted
	 * or FALSE if was not submitted at all or array of messages if was
	 * submitted but not all required values were filled correctly.
	 *
	 * @return boolean|array
	 */
	private function _processRegistrationForm()
	{
		if(!isset($_POST['registerSubmit'])) {
			return false;
		}
		
		$model = new odCatalogWpPlugin_Models_User();
		$values = array();
		
		$values['jazyk'] = (isset($_POST['jazyk'])) ? $_POST['jazyk'] : '';
		$values['narodnost'] = (isset($_POST['narodnost'])) ? $_POST['narodnost'] : '';
		$values['bydliste'] = (isset($_POST['bydliste'])) ? $_POST['bydliste'] : '';
		$values['titul'] = (isset($_POST['titul'])) ? $_POST['titul'] : '';
		$values['jmeno'] = (isset($_POST['jmeno'])) ? $_POST['jmeno'] : '';
		$values['prijmeni'] = (isset($_POST['prijmeni'])) ? $_POST['prijmeni'] : '';
		$values['ulice'] = (isset($_POST['ulice'])) ? $_POST['ulice'] : '';
		$values['mesto'] = (isset($_POST['mesto'])) ? $_POST['mesto'] : '';
		$values['psc'] = (isset($_POST['psc'])) ? $_POST['psc'] : '';
		$values['email'] = (isset($_POST['email'])) ? $_POST['email'] : '';
		$values['mobil'] = (isset($_POST['mobil'])) ? $_POST['mobil'] : '';
		$values['telefon'] = (isset($_POST['telefon'])) ? $_POST['telefon'] : '';
		$values['narozeni'] = (isset($_POST['narozeni'])) ? $_POST['narozeni'] : '';
		$values['pohlavi'] = (isset($_POST['pohlavi'])) ? $_POST['pohlavi'] : '';
		$values['deti'] = (isset($_POST['deti'])) ? $_POST['deti'] : '';
		$values['zajmy'] = (isset($_POST['zajmy'])) ? $_POST['zajmy'] : array();
		$values['souhlas'] = (isset($_POST['souhlas'])) ? $_POST['souhlas'] : '';
		$values['karta'] = (isset($_POST['karta'])) ? $_POST['karta'] : '';
		$values['odkud'] = (isset($_POST['odkud'])) ? $_POST['odkud'] : '';
		
		$values['zajmy'] = join(',', $values['zajmy']);
		
		// TODO Check if values are correct!!!
		
		$res = $model->insert($values);
		
		if(!$res) {
			return array(__(
				'Omlouváme se, ale při ukládání registrace do databáze nastala ' .
				'neznámá chyba. Opakujte, prosíme, registraci a pokud se bude ' .
				'chyba opakovat kontaktujte správce těchto stránek.',
				self::TEXTDOMAIN)
			);
		}
		
		return true;
	}
	
	/**
	 * Renders registration form and returns it.
	 *
	 * @return string
	 */
	public function renderCreateAccountForm()
	{
		// TODO Correct form URL!!!
		$options = $this->getOptions();
		$formUrl = get_option('home') . '/?page_id=' . $options['registration_form_page_id'];
		$output = '';
		
		$res = $this->_processRegistrationForm();
		if($res === true) {
			// TODO Another message!!!
			$output = '<p>' . __('Vaše registrace byla úspěšná. Nyní se můžete přihlásit.', self::TEXTDOMAIN) . '</p>' . PHP_EOL;
			return $output;
		} else if(is_array($res)) {
			foreach($res as $msg) {
				$output .= '<p style="colof:#f30; font-weight: bold;">' . $msg . '</p>';
			}
		}
		
		$categoryModel = new odCatalogWpPlugin_Models_Category();
		$categories = $categoryModel->getAsTree(0, 'en');
		
		$output  = '<form action="registrace.html" method="post">' . PHP_EOL;
		$output .= '	<h3>' . __('Údaje o podniku (budou použité do on-line katalogu)', self::TEXTDOMAIN) . '</h3>' . PHP_EOL;
		$output .= '	<div class="radek">' . PHP_EOL;
		$output .= '		<span class="pole">' . PHP_EOL;
		$output .= '			<label for="titul">' . __('Název podniku:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="titul" id="titul" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '	</div>' . PHP_EOL;
		$output .= '	<div class="radek">' . PHP_EOL;
		$output .= '		<span class="pole">' . PHP_EOL;
		$output .= '			<label for="kategorie">' . __('Kategorie podniku:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<select name="kategorie" id="kategorie">' . PHP_EOL;
		$output .= '				<option value="">' . __('vyberte prosím', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= odWpPlugin_Form::_renderElementOption($categories);
		$output .= '			</select>' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '	</div>' . PHP_EOL;
		$output .= '	<div class="radek">' . PHP_EOL;
		$output .= '		<span class="pole">' . PHP_EOL;
		$output .= '			<label for="popis">' . __('Popis podniku:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<textarea id="popis"></textarea>' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '	</div>' . PHP_EOL;
		$output .= '	<div class="radek">' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="ulice">' . __('Ulice:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="ulice" id="ulice" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="mesto">' . __('Město:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="mesto" id="mesto" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="psc">' . __('PSČ:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="psc" id="psc" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '	</div>' . PHP_EOL;
		$output .= '	<div class="radek">' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="email">' . __('Email 1:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="email" id="email" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="email2">' . __('Email 2:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="email2" id="email2" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="internet">' . __('Internet:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="internet" id="internet" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '	</div>' . PHP_EOL;
		$output .= '	<div class="radek">' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="mobil">' . __('Mobilní telefon:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="mobil" id="mobil" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="telefon">' . __('Pevný telefon:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="telefon" id="telefon" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="fax">' . __('Fax:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="fax" id="fax" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '	</div>' . PHP_EOL;
		$output .= '	<div class="radek">' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="oteviraci">' . __('Otevírací doba:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="oteviraci" id="oteviraci" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="jazyky">' . __('Jazyky:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="jazyky" id="jazyky" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="doprava">' . __('Nejbližší doprava MHD:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="doprava" id="doprava" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '	</div>' . PHP_EOL;
		$output .= '	<div class="radek">' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="kuchyne">' . __('Kuchyně po 23 hod.:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<select name="kuchyne" id="kuchyne">' . PHP_EOL;
		$output .= '				<option value="">' . __('vyberte prosím', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '				<option value="ano">' . __('Ano', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '				<option value="ne">' . __('Ne', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '			</select>' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="rozvoz">' . __('Rozvoz jídel:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<select name="rozvoz" id="rozvoz">' . PHP_EOL;
		$output .= '				<option value="">' . __('vyberte prosím', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '				<option value="ano">' . __('Ano', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '				<option value="ne">' . __('Ne', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '			</select>' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="wifi">' . __('Free Wi-fi:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<select name="wifi" id="wifi">' . PHP_EOL;
		$output .= '				<option value="">' . __('vyberte prosím', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '				<option value="ano">' . __('Ano', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '				<option value="ne">' . __('Ne', self::TEXTDOMAIN) . '</option>' . PHP_EOL;
		$output .= '			</select>' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '	</div>' . PHP_EOL;
		$output .= '	<p class="datum">&nbsp;</p>' . PHP_EOL;
		$output .= '	<p class="oddeleni"></p>' . PHP_EOL;
		$output .= '	<h3>' . __('Osobní údaje (pro sjednání osobní schůzky)', self::TEXTDOMAIN) . '</h3>' . PHP_EOL;
		$output .= '	<div class="radek">' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="jmeno">' . __('Jméno:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="jmeno" id="jmeno" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="prijmeni">' . __('Příjmení:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="prijmeni" id="prijmeni" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="email_kontakt">' . __('Email:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="email_kontakt" id="email_kontakt" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '	</div>' . PHP_EOL;
		$output .= '	<div class="radek">' . PHP_EOL;
		$output .= '		<span class="formular">' . PHP_EOL;
		$output .= '			<label for="telefon_kontakt">' . __('Telefon:', self::TEXTDOMAIN) . '</label>' . PHP_EOL;
		$output .= '			<input type="text" name="telefon_kontakt" id="telefon_kontakt" value="" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '	</div>' . PHP_EOL;
		$output .= '	<p class="datum">&nbsp;</p>' . PHP_EOL;
		$output .= '	<p class="oddeleni"></p>' . PHP_EOL;
		$output .= '	<div class="radek">' . PHP_EOL;
		$output .= '		<span class="formular siroky">' . PHP_EOL;
		$output .= '			<input type="submit" value="' . __('Odeslat', self::TEXTDOMAIN) . '" class="odeslat" />' . PHP_EOL;
		$output .= '		</span>' . PHP_EOL;
		$output .= '	</div>' . PHP_EOL;
		$output .= '</form>' . PHP_EOL;
		
		return $output;
	}
	
	/**
	 * Process create account form. Returns TRUE if form was correctly 
	 * submitted or FALSE if was not submitted at all or array of messages 
	 * if was submitted but not all required values were filled correctly.
	 *
	 * @return boolean|array
	 */
	private function _processCreateAccountForm()
	{
		if(!isset($_POST['registerSubmit'])) {
			return false;
		}
		
		$model = new odCatalogWpPlugin_Models_User();
		$values = array();
		
		// ...
		
		return true;
	}
	
} // End of odCatalogWpPlugin

endif;
#}}} --- odCatalogWpPlugin

if(class_exists('odCatalogWpPlugin')):
// Initialize plugin
$od_catalog_wpplugin = odCatalogWpPlugin::getInstance();
endif;
